<?php
class Bestmagento_BmProducts_Block_Product_Listbest extends Mage_Catalog_Block_Product_List{

    protected function _getProductCollection()
    {
        if (is_null($this->_productCollection)) {
            $this->_productCollection = Mage::getResourceModel('bmproducts/reports_product_collection');
               
            $this->_productCollection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
            $this->_productCollection = $this->_addProductAttributesAndPrices( $this->_productCollection);
            $this->_productCollection->addOrderedQty()
                ->addAttributeToSelect('ordered_qty')
                ->setOrder('ordered_qty', 'desc');
        }
        return $this->_productCollection;

    }
     public function getAvailableOrders(){
    
     return array('ordered_qty'=>'OrderedQty','price'=>'Price','name'=>'Name');
    }
    public function getDefaultDirection(){
    
      return 'desc';
    }

}  
